import threading
import time


# 示例函数，模拟一些工作
def worker(name, delay):
    print(f"线程 {name} 开始")
    time.sleep(delay)
    print(f"线程 {name} 结束")


if __name__ == "__main__":
    # 创建线程
    thread1 = threading.Thread(target=worker, args=("A", 3))
    thread2 = threading.Thread(target=worker, args=("B", 2))

    # 启动线程
    thread1.start()
    thread2.start()

    # 等待所有线程完成
    thread1.join()
    thread2.join()

    print("所有线程已结束")
